<template>
  <el-dialog title="备注记录" :visible.sync="dialogVisible" width="1000px">
    <el-table :data="tableData" border>
      <el-table-column label="备注信息" prop="remark" />
      <el-table-column label="操作人员" prop="username" width="200" />
      <el-table-column label="时间" prop="create_time" width="200" />
      <el-table-column align="center" label="操作" width="180">
        <template slot-scope="scope">
          <el-button type="warning" size="mini" @click="del_remark(scope.row.id)">删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <custom-page ref="customPage" :total="total" @getList="getList" />
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="dialogVisible = false">关闭</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { getOrderRemark,delRemark } from '@/api/order'
import customPage from '@/components/customPage'
export default {
  components: { customPage },
  // props: ['orderId'],
  props: {
    orderId: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      dialogVisible: false,
      tableData: [],
      total: 0
    }
  },
  watch: {
    dialogVisible(val) {
      if (val) {
        this.$nextTick(() => {
          this.getList()
        })
      }
    }
  },
  methods: {
    getList() {
      const { page, pageSize } = this.$refs.customPage
      getOrderRemark({ page, pageSize, orderId: this.orderId }).then(res => {
        this.tableData = res.data || []
        this.total = res.total || 0
      })
    },
	del_remark(id){
		this.$confirm('是否删除?', '提示', {
		  confirmButtonText: '我要删',
		  cancelButtonText: '先不删'
		})
		  .then(() => {
			  console.log(1);
		    delRemark({id}).then(res => {})
		    this.getList()
		  })
		  .catch(() => { })
	}
  }
}
</script>

<style lang="scss" scoped>
</style>
